From 4cd3c56765485eddfc3be8484519053a79e4ee44 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 2 Oct 2015 22:27:41 +0200 Subject: [PATCH] Do not skip the root path if it's a dotdir When traversing the directory tree, cargo will omit paths that start with a period character to avoid interfering with other software. Unfortunately this also prevents a crate from being located in a directory prefixed with a period. Address this by extending the test against the traversal root that already guards Git submodules. Fixes issue #1999 which was introduced with commit 11144645f.. --- src/cargo/ops/cargo_read_manifest.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/cargo/ops/cargo_read_manifest.rs b/src/cargo/ops/cargo_read_manifest.rs index 741445510..319bf80f2 100644 --- a/src/cargo/ops/cargo_read_manifest.rs +++ b/src/cargo/ops/cargo_read_manifest.rs @@ -43,15 +43,17 @@ pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config) try!(walk(path, &mut |dir| { trace!("looking for child package: {}", dir.display()); - // Don't recurse into hidden/dot directories - let name = dir.file_name().and_then(|s| s.to_str()); - if name.map(|s| s.starts_with(".")) == Some(true) { - return Ok(false) - } - - // Don't automatically discover packages across git submodules - if dir != path && fs::metadata(&dir.join(".git")).is_ok() { - return Ok(false) + // Don't recurse into hidden/dot directories unless we're at the toplevel + if dir != path { + let name = dir.file_name().and_then(|s| s.to_str()); + if name.map(|s| s.starts_with(".")) == Some(true) { + return Ok(false) + } + + // Don't automatically discover packages across git submodules + if fs::metadata(&dir.join(".git")).is_ok() { + return Ok(false) + } } // Don't ever look at target directories -- 2.30.2